package cn.cjxy.javaweb.servlet.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author huangjie
 * @date 2025/9/29
 */
@WebServlet("/query")
public class QueryServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        //取出
        HttpSession session = req.getSession();
        Person person =(Person) session.getAttribute("person");
        PrintWriter writer = resp.getWriter();
        writer.println("访问成功....会话id"+session.getId());
        writer.println("perosn:-----"+person);

    }
}
